package com.saw;

import java.util.HashSet;

public class HashSetDemo02 {
    public static void main(String[] args) {
        HashSet<Student> hs = new HashSet<>();

//        创建学生对象
        Student s1 = new Student("小爱同学", 26);
        Student s2 = new Student("小王同学", 27);
        Student s3 = new Student("小宋同学", 28);

        hs.add(s1);
        hs.add(s2);
        hs.add(s3);

//       使用增强for 循环遍历 hashSet 对象

        for (Student s:hs){
            System.out.println(s.getName()+","+s.getAge());
        }


    }
}
